package kmp;

import java.util.Scanner;



// 求模式串中最多有几个前缀在主串中
public class Test04 {

    private static int[] next = new int[1000000];
    private static int maxx = 0;

    static void GenNext(String s){
        int k = -1;
        int j = 0;
        int len = s.length();
        next[0] = -1;

        while(j < len-1){
            if(k == -1 || s.charAt(k) == s.charAt(j)){
                k++;
                j++;
                next[j] = k;
            }else{
                k = next[k];

            }
        }

    }

    static int kmp(int start,String s1,String s2){
        int len1 = s1.length();
        int len2 = s2.length();
        int i = start;
        int j = 0;
        while(i < len1 && j < len2){
            if(j==-1||s1.charAt(i) == s2.charAt(j)){
                i++;
                j++;
            }else{
                j = next[j];

            }
            maxx = max(maxx,j);
        }
        if(i == len1){
            return -1;
        }else{
            return (i - j);
        }
    }

    private static int max(int num1, int num2) {
        int res;
        if(num1 > num2){
            res = num1;
        }else{
            res = num2;
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S,T;
        S = scanner.next();
        T = scanner.next();
        GenNext(T);
        kmp(0,S,T);
        System.out.println(maxx);
    }
}
